import { fromJS } from 'immutable';
import * as constants from './constants';

const defaultState = fromJS({
  tasks: [],
  historyTasks: [],
  taskLog: {},
  taskInfo: {},
});

export default(state=defaultState, action) => {
  switch(action.type){
    case constants.GET_TASK_LIST:
      return state.set('tasks',action.tasks);
    case constants.GET_HISTORY_TASK_LIST:
      return state.set('historyTasks',action.tasks);
    case constants.GET_TASK_LOG:
      return state.set('taskLog',action.taskLog);
    case constants.GET_TASK_INFO:
      return state.set('taskInfo',action.taskInfo);
    default: return state;
  }
}